//引入公共样式
require("../../assets/css/index.less");
require("./login.less");
// 引入公用js模块
let dom = require("../../utils/dom.js");
let https = require("../../utils/https.js");
let local = require("../../utils/local.js");
window.addEventListener("DOMContentLoaded",function(){
  //切页面
  dom.jump("#jump", "register");
  dom.jump("#tip", "back");
  //登录功能
  dom.getEle("#submit").addEventListener("click", function () {
    let account = dom.getEle("#phone").value;
    let password = dom.getEle("#password").value;
    if (account && password) {
      https.post("/api/user/login", { account, password }, function (res) {
        if (res.errno == 0) {
          //登录成功
          alert("恭喜您!登录成功!");
          local.set("t_k", res.data.token);
          location.href = "home.html";
        } else {
          //登录失败
          alert("账号或密码有误!");
        }
      });
    }
  });
});
